<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ page import="edu.itla.medifacil.persistence.enums.Attribute" %>
<%@ page import="edu.itla.medifacil.persistence.entities.People" %>
<%@ page import="edu.itla.medifacil.helpers.Utilities" %>
<%@ page import="edu.itla.medifacil.persistence.entities.PersonAttributesValue" %>
<%@page import="java.util.*;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	<link rel="stylesheet" href="../css/style.css" />
	
	

	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<title>Pacientes</title>
	
	<% 
		if( request.getSession().getAttribute("patients") == null ){
			System.out.println("Entre");
			response.sendRedirect("/MediFacil/Patients.do"); 
		}
	%>
</head>
<body>
	<jsp:include page="../navigation/header.jsp" >
		<jsp:param value="patients" name="active"/>
	</jsp:include>

	<div id="container">
		<a class="action" href="/MediFacil/patients/add.jsp" >Agregar Paciente</a>
		
		<div class="clear"></div>
	<% 
		for( People patient : (List<People>)request.getSession().getAttribute("patients") ) { 
			Map<Integer, String> patientAttributes = Utilities.extractPersonAttributes(patient);
	%>
	
		<div class="patient">
			<div class="picture floatL">
			<% 
				String picture = "../img/unknown.png"; 
				if( patientAttributes.get( Attribute.FOTO.getId() ) != null && patientAttributes.get( Attribute.FOTO.getId() ).length() > 0 )
					picture = ".." + patientAttributes.get( Attribute.FOTO.getId() );
			%>
			
			<img width="60" height="60" src="<%= picture %>" />
			</div>
			
			<div class="info floatR">
				<p>
					<a href="/MediFacil/Patients.do?action=view&id=<%= patient.getId() %>"><%= patient.getName() + " " + patient.getLastName() %></a>
				</p>
				<p><b><%= patient.getIdentification() %></b></p>
				<% if( patientAttributes.get( Attribute.TELEFONO.getId() ) != null && patientAttributes.get( Attribute.TELEFONO.getId() ).length() > 0 ) {%>
					<p>Tel.: <%= patientAttributes.get( Attribute.TELEFONO.getId() ) %></p>
				<%} %>
				<% if( patientAttributes.get( Attribute.CELULAR.getId() ) != null && patientAttributes.get( Attribute.CELULAR.getId() ).length() > 0 ) {%>
					<p>Cel.: <%= patientAttributes.get( Attribute.CELULAR.getId() ) %></p>
				<%} %>
			</div>
		</div>
	<% }//End foreach %>
		<div class="clear"></div>
	</div>
	
	<jsp:include page="../navigation/copyright.html" />
</body>
</html>